does anyonf have any experience with the EVAL_ command? I was told that EVAL_ could be used within a DXL script to trigger the start of another DXL script. |
Re: EVAL_ Command
Yes, you can send a script to eval_ and it will run it in its own context. 'Own Context' means the eval script will not have access to any of the main scripts variables nor functions; which likewise means you cannot pass in any sort of 'Module' et tal handle. If the eval DXL wants to deal with a module you'll need to pass that name in, and the eval script must open it.
// eval_ demo
/*
run from any current module,preferably one with deleted objects
*/
string NameMod = fullName(current Module)
string EvalCode =
"Module mod = read(\"" NameMod "\", false)
Object obj
int Count = 0
if (confirm(\"Count displayed objects only?\"))
{ for obj in mod do Count++
return_(\"Number Displayed objects = \" Count \"\")
}
else
{ for obj in entire mod do Count++
return_(\"Number of All objects = \" Count \"\")
}
// close(mod) // Interesting, this will close the main open module
" // end definition of string EvalCode
string ErrMess = checkDXL(EvalCode)
if (!null ErrMess)
{ print "Error in EvalCode ======\n" ErrMess
print "-------------\n" EvalCode "\n=============\n"
}
else
{ string Returned
noError
if (confirm("Introduce DXL Errors"))
Returned = eval_("xx = yy\n" EvalCode)
else Returned = eval_(EvalCode)
ErrMess = lastError
if (!null ErrMess)
print "====ErrMess in EvalCode ===\n" ErrMess "=========\n"
else print "Returned Code =========\n" Returned "\n=============\n"
}
// print "EvalCode ---------------\n" EvalCode "\n-------------\n"
|
Re: EVAL_ Command llandale - Sun Aug 16 14:56:46 EDT 2009
Yes, you can send a script to eval_ and it will run it in its own context. 'Own Context' means the eval script will not have access to any of the main scripts variables nor functions; which likewise means you cannot pass in any sort of 'Module' et tal handle. If the eval DXL wants to deal with a module you'll need to pass that name in, and the eval script must open it.
// eval_ demo
/*
run from any current module,preferably one with deleted objects
*/
string NameMod = fullName(current Module)
string EvalCode =
"Module mod = read(\"" NameMod "\", false)
Object obj
int Count = 0
if (confirm(\"Count displayed objects only?\"))
{ for obj in mod do Count++
return_(\"Number Displayed objects = \" Count \"\")
}
else
{ for obj in entire mod do Count++
return_(\"Number of All objects = \" Count \"\")
}
// close(mod) // Interesting, this will close the main open module
" // end definition of string EvalCode
string ErrMess = checkDXL(EvalCode)
if (!null ErrMess)
{ print "Error in EvalCode ======\n" ErrMess
print "-------------\n" EvalCode "\n=============\n"
}
else
{ string Returned
noError
if (confirm("Introduce DXL Errors"))
Returned = eval_("xx = yy\n" EvalCode)
else Returned = eval_(EvalCode)
ErrMess = lastError
if (!null ErrMess)
print "====ErrMess in EvalCode ===\n" ErrMess "=========\n"
else print "Returned Code =========\n" Returned "\n=============\n"
}
// print "EvalCode ---------------\n" EvalCode "\n-------------\n"
I have a dxl script with a GUI. If the user clicks a certain button on the GUI I'd like to run another scipt. This other script is called Run_Report.dxl. It is in the same directory as the running script. How would I use the eval_ command to run the script that is contained in the Run_Report.dxl file? Thank you again for the help. David Schwartz |
Re: EVAL_ Command SystemAdmin - Mon Aug 17 09:15:34 EDT 2009 If you do know the exact path to the file, you can eval_("#include <c:\MyFolder\MyDXL\MyOtherFile.dxl>") But it will wait for the other script to end before returning, as will simply issuing the #include statement in that certain button's callback function.
|
Re: EVAL_ Command llandale - Mon Aug 17 10:05:29 EDT 2009
eval_("#include <c:\DXL\Pass_Fail_Counter.dxl>") When I try to run the script from the DXL Editor windoe I get the following error message: badly formed token ("#include) Thanks again for the help. David Schwartz |
Re: EVAL_ Command SystemAdmin - Mon Aug 17 10:30:20 EDT 2009 eval_("#include <c:\\DXL\\Pass_Fail_Counter.dxl>") eval_("#include <c:/DXL/Pass_Fail_Counter.dxl>")
I now notice that the eval_ DXL environment is not that same as the GUI. For example you cannot refer to the 'obj' which is predefined for layouts and attrDxL. if (null obj) return("") else return(identifier(obj)) works in the GUI, but not in eval_. Hopefully someone else will comment on that. |
Re: EVAL_ Command llandale - Mon Aug 17 12:02:47 EDT 2009
I now notice that the eval_ DXL environment is not that same as the GUI. For example you cannot refer to the 'obj' which is predefined for layouts and attrDxL. if (null obj) return("") else return(identifier(obj)) works in the GUI, but not in eval_. Hopefully someone else will comment on that. David Schwartz |
Re: EVAL_ Command llandale - Mon Aug 17 12:02:47 EDT 2009
I now notice that the eval_ DXL environment is not that same as the GUI. For example you cannot refer to the 'obj' which is predefined for layouts and attrDxL. if (null obj) return("") else return(identifier(obj)) works in the GUI, but not in eval_. Hopefully someone else will comment on that. The way around the obj issue is to pass all the information that you need to the eval_ perm as follows: eval_("int objAbsNo = " obj."Absolute Number" "\nstring attrDXLName = \"" attrDXLName "\"\n#include <c:\\temp\\dxlTest.dxl>") In your dxl file (dxlTest.dxl in my example) you can use the passed-in information as follows: Object obj = object(objAbsNo) obj.attrDXLName = identifier(obj) "" For this code I made a Text type attribute DXL where I placed the eval_ statement. |